'use strict';

const Controller = require('egg').Controller;

class TjbbController extends Controller {
    async index1() {
        const { ctx, service } = this;
        await ctx.render('/fpdk/zpdksh/index.html');
    }

    async index2() {
        const { ctx, service } = this;
        await ctx.render('/fpdk/zptj/index.html');
    }

    async chakan() {
        const { ctx, service } = this;
        const params = ctx.query;
        //  console.log('--------------kkk');
        //  console.log(params);
        const result = await ctx.service.fpdk.fpdkService.chakan1(params);
        const data = result.data.data;
        await ctx.render('/fpdk/zptj/chakan.html', { data: data, params: params });
    }


    async detail() {
        const { ctx, service } = this;
        const params = ctx.query;
        const result = await ctx.service.fpdk.fpdkService.detaildate(params);
        ctx.logger.info(result);
        const data = result.data.data;
        await ctx.render('/fpdk/zpdksh/detail.html', { data: data });
        //  console.log('------------xx');
        //  console.log(data);
    }

    async detail2() {
        const { ctx, service } = this;
        const params = ctx.query;
        const result = await ctx.service.fpdk.fpdkService.detaildate(params);
        const data = result.data.data;
        await ctx.render('/fpdk/zpdksh/update.html', { data: data });
    }

    // 查
    async list() {
        const ctx = this.ctx;
        const params = ctx.query;
        const result = await ctx.service.fpdk.fpdkService.list(params);
        const data = result.data.data.list;

        const tableresult = {
            code: result.data.code,
            msg: result.data.msg,
            count: result.data.data.total,
            data: result.data.data.list,
        };
        ctx.body = tableresult;
    }

    // 查
    async list_tg() {
        const ctx = this.ctx;
        const params = ctx.query;
        const result = await ctx.service.fpdk.fpdkService.list_tg(params);
        const data = result.data.data.list;
        const tableresult = {
            code: result.data.code,
            msg: result.data.msg,
            count: result.data.data.total,
            data: result.data.data.list,
        };
        ctx.body = tableresult;
    }

    // 查
    async select_jgdm() {
        const ctx = this.ctx;
        const params = ctx.query;
        const result = await ctx.service.fpdk.fpdkService.select_jgdm(params);
        const data = result.data.data;
        const tableresult = {
            code: result.data.code,
            msg: result.data.msg,
            count: result.data.total,
            data: result.data.data
        };

        //  console.log('--------iii');
        //  console.log(result.data);
        ctx.body = tableresult;
    }

    async chakan1() {
        const { ctx, service } = this;
        const params = ctx.query;

        const result = await ctx.service.fpdk.fpdkService.chakan1(params);
        const data = result.data.data.list;
        const tableresult = {
            code: result.data.code,
            msg: result.data.msg,
            count: result.data.data.total,
            data: result.data.data.list
        };
        ctx.body = tableresult;
    }

    async detaildate() {
        const ctx = this.ctx;
        const params = ctx.query;
        const result = await ctx.service.fpdk.fpdkService.detaildate(params);
        ctx.body = result;
    }


    async detaildate99() {
        const { ctx, service } = this;
        const params = ctx.query;
        //  console.log('-----------9999');
        //  console.log(params.id)
        const result = await ctx.service.fpdk.fpdkService.detaildate99(params);
        const data = result.data.data.hlmxs;
        const tableresult = {
            code: result.data.code,
            msg: result.data.msg,
            count: result.data.data.total,
            data: result.data.data.hlmxs
        };


        ctx.body = tableresult;
    }

    async detaildate2() {
        const ctx = this.ctx;
        const params = ctx.query;
        const result = await ctx.service.fpdk.fpdkService.detaildate(params);
        const data = result.data.data;

        const tableresult = {
            code: result.data.code,
            msg: result.data.msg,
            count: result.data.data.total,
            data: result.data.data
        };

        ctx.body = tableresult;
    }

    // 改
    async update() {
        const ctx = this.ctx;
        const params = ctx.query;
        const result = await ctx.service.fpdk.fpdkService.update(params);
        ctx.body = result;
    }

    // 删
    async delete() {
        const ctx = this.ctx;
        const params = ctx.request.body;
        const result = await ctx.service.fpdk.fpdkService.delete(params);
        ctx.body = result;
    }
    async detaildata() {
        const ctx = this.ctx;
        const params = ctx.request.body;
        const result = await ctx.service.fpdk.fpdkService.detaildata(params);
        ctx.body = result;
    }
}

module.exports = TjbbController;